<div>
<table width="100%">
	<tr>
		
		<td width="33%"><a href="index.php"><img src="<?php echo "domains/$domain/title.png" ?>" /></a></td>
		<td width="33%">
			<div class="link-div">
				<table>
				<!-- <tr><td><b>Friends:</b></td></tr> -->
				
				<tr><td>
				<?php 
				$query="SELECT f.name, f.url FROM friends f
				join domain d on d.id = f.domain_id
				where d.name = '$domain'
				order by f.index";
				$mainresult=mysql_query($query);
				$num=mysql_numrows($mainresult);			
				$i=0;
				while ($i < $num) {
					
					if ($i > 0 && $i%4 == 0) {
						echo '</td><td>';
					}
					
					$domainname=mysql_result($mainresult,$i,"name");
					$url=mysql_result($mainresult,$i,"url");
					
					echo ($i+1).'. <a href="'.$url.'"><span class="link">'.$domainname.'</span></a><br/>';
					$i++;
				}
				
				?>
					<!-- <tr><td><a href="list.php"><span class="link">All Galleries</span></a></td></tr> -->
				</td></tr></table>
			</div>
		</td>
	</tr>
</table>
</div>